// ==UserScript==
// @name         Acfun直播自动点赞jQuery
// @namespace    http://zerowuchina.oschina.io/base/
// @version      0.0.2
// @icon         http://cdn.aixifan.com/ico/favicon.ico
// @description  自动点赞机器人
// @author       Zero Wu
// @include      https://live.acfun.cn/live/*
// @require      http://lib.sinaapp.com/js/jquery/1.12.4/jquery-1.12.4.min.js
// @updateURL    https://gitee.com/zerowuchina/base/raw/master/js/acfunAutoLikes.meta.js
// @downloadURL  https://gitee.com/zerowuchina/base/raw/master/js/acfunAutoLikes.user.js
// @grant        none
// @run-at       document-end
// ==/UserScript==
$(document).ready(function () {
    var b2 = $(".author-interactive-area");
    var btn = $(".like-btn");
    var flag = null;
    var s = true;

    var b3 = document.createElement('button');
    b3.innerText = '自动点赞';
    b3.id = 'likesBtn';
    b2.append(b3);

    $('#likesBtn')[0].addEventListener("click",f);

    function f() {
        if(s === true) {
            b3.innerText="停止";
            flag = setInterval(clicked,200);
        } else {
            b3.innerText="开始";
            clearInterval(flag);
        }
        s=!s;
    }

    function clicked(){
        if(btn !== null) {
                btn.click();
                //console.log("点赞");
        } else{
                console.log("没有按钮");
        }
    }
});